namespace IntetfaceEditor4PDA
{
    public class SQLControlsReader
    {
        public static bool Light = false;
        public const string InsertQry = "insert into QryList(idQryList, text) values ({0}, '{1}')";
        public const string SelectGetNewIdclsQry = "select max(idQryList+1) as ID from QryList";
        public const string InsertclsFlag = "insert into CheckingFlags(idCheckingFlag, text) values ({0}, '{1}')";
        public const string SelectGetNewIdclsFlag = "select max(idCheckingFlag+1) as ID from CheckingFlags";
        public const string SelectAllFlags = "select * from CheckingFlags";
        public const string SelectAllQuery = "select * from QryList";
        public const string UpdateControl = "update ControlInterface set idControlType = {1}, fieldName = '{2}', controlName = '{3}', controlLenght = {4}, controlLinesCount = {5}, checkTrue = {6}, checkFalse = {7}, idQryList = {8}, valType = {9}, minVal = {10}, maxVal= {11} where idControlInterface = {0}";
        
        
        public const string _SetSheetPinterNull = "update SheetInterface set idTopControl = NULL where idTopControl = {0}";
        public const string __SetSheetPinterNull = "update SheetInterfaceLite set idTopControl = NULL where idTopControl = {0}";
        public static string SetSheetPinterNull
        {
            get { return Light?__SetSheetPinterNull:_SetSheetPinterNull; }
        }

        public const string _UpadteSheetChildItemName = "update SheetInterface set sheetName = '{1}', hasGrid = {2}, tableName = '{3}',orderBy='{4}' where idSheetInterface = {0}";
        public const string __UpadteSheetChildItemName = "update SheetInterfaceLite set sheetName = '{1}', qryText = '{3}',orderBy='{4}' where idSheetInterfaceLite = {0}";
        public static string UpadteSheetChildItemName
        {
            get { return Light ? __UpadteSheetChildItemName : _UpadteSheetChildItemName; }
        }        
        
        public const string _UpadteSheetTopItemName = "update SheetInterface set sheetName = '{1}' where idSheetInterface = {0}";
        public const string __UpadteSheetTopItemName = "update SheetInterfaceLite set sheetName = '{1}' where idSheetInterfaceLite = {0}";
        public static string UpadteSheetTopItemName
        {
            get { return Light ? __UpadteSheetTopItemName : _UpadteSheetTopItemName; }
        }
        
        
        
        public const string InsertNewChildControl = "insert into ControlInterface(idControlInterface, idOwnControl, idControlType, controlName) values ({0}, {1}, {2}, '{3}')";
        public const string DeleteControl = "delete from ControlInterface where idControlInterface = {0}";
        
        public const string _UpdateSheetSetTop = "update SheetInterface set idTopControl = {1} where idSheetInterface = {0}";
        public const string __UpdateSheetSetTop = "update SheetInterfaceLite set idTopControl = {1} where idSheetInterfaceLite = {0}";
        public static string UpdateSheetSetTop
        {
            get { return Light ? __UpdateSheetSetTop : _UpdateSheetSetTop; }
        }        
        
        public const string SelectInterfaceByID = "select * from ControlInterface where idControlInterface = {0}";
        
        public const string _DellInterfaceItem = "delete from SheetInterface where idSheetInterface = {0}";
        public const string __DellInterfaceItem = "delete from SheetInterfaceLite where idSheetInterfaceLite = {0}";
        public static string DellInterfaceItem
        {
            get { return Light ? __DellInterfaceItem : _DellInterfaceItem; }
        }         
        
        public const string SelectBoolValById = "select * from CheckingFlags where idCheckingFlag={0}";
        public const string SelectGridMainParam = "select * from ControlInterface where idOwnControl = {0} and idControlType = " + ControlType.GridGroup;
        public const string SelectInterfaceByParent = "select * from ControlInterface where idOwnControl = {0} "; // order by idControlInterface
        public const string SelectInterfaceByParentNotGrid = "select * from ControlInterface where idOwnControl = {0} and idControlType <> " + ControlType.GridGroup;
        public const string SelectQueryById = "select * from QryList where idQryList={0}";
        
        public const string _SelectParamsEdit = "select * from SheetInterface";
        public const string __SelectParamsEdit = "select * from SheetInterfaceLite";
        public static string SelectParamsEdit
        {
            get { return Light ? __SelectParamsEdit : _SelectParamsEdit; }
        }

        public const string _SelectGetNewIdSheetInterface = "select max(idSheetInterface+1) as ID from SheetInterface";
        public const string __SelectGetNewIdSheetInterface = "select max(idSheetInterfaceLite+1) as ID from SheetInterfaceLite";
        public static string SelectGetNewIdSheetInterface
        {
            get { return Light ? __SelectGetNewIdSheetInterface : _SelectGetNewIdSheetInterface; }
        }        
        
        public const string _InsertNewTopSheet = "insert into SheetInterface(idSheetInterface, sheetName) values ({0}, '{1}')";
        public const string __InsertNewTopSheet = "insert into SheetInterfaceLite(idSheetInterfaceLite, sheetName) values ({0}, '{1}')";
        public static string InsertNewTopSheet
        {
            get { return Light ? __InsertNewTopSheet : _InsertNewTopSheet; }
        }         
        
        public const string _InsertNewChildSheet = "insert into SheetInterface(idSheetInterface, sheetName, idOwnSheet) values ({0}, '{1}', {2})";
        public const string __InsertNewChildSheet = "insert into SheetInterfaceLite(idSheetInterfaceLite, sheetName, idOwnSheet) values ({0}, '{1}', {2})";
        public static string InsertNewChildSheet
        {
            get { return Light ? __InsertNewChildSheet : _InsertNewChildSheet; }
        }        
        
        public const string SelectGetNewIdControlInterface = "select max(idControlInterface+1) as ID from ControlInterface";
        public const string InsertNewTopControl = "insert into ControlInterface(idControlInterface, idControlType, controlName) values ({0}, 0, 'Top')";
    }
}